$(window).on("pagechange", function() {
	initialize();
	var h = $(window).height();
	$(".fulldiv").height(h - 78);
});
function initialize() {
	var geocoder = new google.maps.Geocoder();
	var latlng = new google.maps.LatLng(-33.455273, -70.587851);

	var address = document.getElementById('direccion').value;
	address = address + ", " + $("#comuna").val() + ", chile ";
	geocoder.geocode({
		'address' : address
	}, function(results, status) {
		if (status == google.maps.GeocoderStatus.OK) {
			latlng = results[0].geometry.location;
		}
		setMarker(latlng);
	});
}
function setMarker(latlng) {
	var mapOptions = {
		zoom : 14,
		center : latlng,
		rotateControl : true
	};
	var map = new google.maps.Map(document.getElementById('map-canvas'),
			mapOptions);
	var marker = new google.maps.Marker({
		map : map,
		position : latlng,
		draggable : true
	});
	updatePosition(latlng);
	google.maps.event.addListener(marker, 'dragend', function() {
		updatePosition(marker.getPosition());
	});
}
function updatePosition(latLng) {

	$('#latitud').val(latLng.lat());
	$('#longitud').val(latLng.lng());
}
google.maps.event.addDomListener(window, 'load', initialize);